// 签名功能常量与开关（仅声明与结构，不含具体实现）

export const SIGN_HEADER_NAME = "sign";
export const TIMESTAMP_HEADER_NAME = "timestamps";
export const APP_VERSION_HEADER_NAME = "WebVersion";
export const PLAIN_DEBUG_HEADER_NAME = "X-Sign-Plain-Debug"; // 仅开发环境可选发送

// 是否启用签名功能：默认 false，避免未配置公钥时影响请求
export const SIGN_ENABLED: boolean = String((import.meta as any).env?.VITE_APP_SIGN_ENABLED || "false") === "true";

// 应用版本（分端）：
// Web 端读取 VITE_APP_VERSION；App 端读取 VITE_APP_VERSIONAPP（兼容 VITE_APP_VERSION_APP）
export const APP_VERSION_WEB: string = (import.meta as any).env?.VITE_APP_VERSION || "1.0.0";
export const APP_VERSION_APP: string =
  (import.meta as any).env?.VITE_APP_VERSIONAPP ||
  (import.meta as any).env?.VITE_APP_VERSION_APP ||
  "4.5.0";

// RSA 公钥（PEM 格式）。建议运行时由后端下发并覆盖此值
export const RSA_PUBLIC_KEY: string = (import.meta as any).env?.VITE_APP_SIGN_PUBLIC_KEY || "";

// 拦截器白名单（无需附加 sign 的接口）。可按需扩展
export const SIGN_SKIP_LIST: Array<RegExp | string> = [
  /\/login(\b|\/)/,
  /\/time\/(sync|now)(\b|\/)/,
  /\/timestamps\/current(\b|\/)/,
  /\/platform\/time(\b|\/)/  // App端时间戳接口
];

// 是否在签名中包含 baseURL 的路径前缀（例如 /installer-admin）
export const SIGN_URI_WITH_BASE_PREFIX: boolean = String((import.meta as any).env?.VITE_APP_SIGN_URI_WITH_BASE || "true") === "true";

// 开发环境是否透传明文便于对拍
export const SIGN_DEBUG: boolean = String((import.meta as any).env?.VITE_APP_SIGN_DEBUG || (import.meta as any).env?.DEV || "false") === "true";


